# -*- coding: utf-8 -*-
# @Create_time   :2023-10-12 10:00:00
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :__init__.py
# @Desc          : 派件费日月汇总数据导入tidb

from spmi_fee_domain.dm.dm_spmi_piece_bill_fee_aggr_dt import spmi_dm__dm_spmi_piece_bill_fee_aggr1_dt
from spmi_fee_domain.dm.dm_spmi_piece_bill_fee_aggr_dt import spmi_dm__dm_spmi_piece_bill_fee_aggr3_dt
from spmi_fee_domain.dm.dm_spmi_piece_bill_fee_aggr_dt import spmi_dm__dm_spmi_piece_bill_fee_aggr5_dt
from spmi_fee_domain.time_sensor.time_after_06_30 import time_after_06_30
from spmi_fee_domain.time_sensor.time_after_07_00 import time_after_07_00
from datetime import timedelta
from airflow.operators.bash import BashOperator
from airflow.models import Variable

# pro
tidb_host = Variable.get('bigdata_tidb_host')
tidb_port = Variable.get('bigdata_tidb_port')
tidb_url = Variable.get('bigdata_tidb_url')
tidb_user = Variable.get('bigdata_tidb_user')
tidb_password = Variable.get('bigdata_tidb_password')

# uat tidb  uat-jms-tidb.yl.com 4001 yl_spmibill_report_rw  ZzA^G@4oJFCIjGbk
# tidb_host = "uat-jms-tidb.yl.com"
# tidb_port = 4001
# tidb_url = "jdbc:mysql://uat-jms-tidb.yl.com:4001/spmi_dm?useUnicode=true"
# tidb_user = "yl_spmibill_report_rw"
# tidb_password = "ZzA^G@4oJFCIjGbk"

# ############hive to tidb的信息############
# hive表默认分区表 分区为dt  如不是请跟进自己表进行调整sqoop命令
hive_table1='spmi_tmp.dm_spmi_piece_bill_fee_aggr1_dt'
hive_table3='spmi_tmp.dm_spmi_piece_bill_fee_aggr3_dt'
hive_table5='spmi_tmp.dm_spmi_piece_bill_fee_aggr5_dt'
# tidb信息
tidb_table1='spmi_dm.yl_jms_spmi_piece_bill_sum_pt_1'
tidb_table3='spmi_dm.yl_jms_spmi_piece_bill_sum_pt_3'
tidb_table5='spmi_dm.yl_jms_spmi_piece_bill_sum_pt_5'
# tidb是否是分区表 true ：tidb是分区表  false：tidb不是分区表
if_partitions='true'
# 每次推送天数
interval_dt=60
# 推送map个数（最大100map 一般20-50即可在15分钟内推送亿级别数据）
sqoop_maps=20

tidb_dm_spmi_piece_bill_fee_aggr1_dt = BashOperator(
    task_id='tidb_dm_spmi_piece_bill_fee_aggr1_dt',
    execution_timeout=timedelta(hours=5),
    email=['lukunming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    bash_command="spmi_fee_domain/dm/tidb/tidb_dm_spmi_piece_bill_fee_aggr_dt/execute.sh",
    pool='spmi_piece',
    retries=0,
    pool_slots=1,
    params={'tidb_host':tidb_host,'tidb_port':tidb_port,'tidb_url':tidb_url,'tidb_user':tidb_user,'tidb_password':tidb_password,'hive_table':hive_table1,'tidb_table':tidb_table1,'if_partitions':if_partitions,'interval_dt':interval_dt,'sqoop_maps':sqoop_maps}

)

tidb_dm_spmi_piece_bill_fee_aggr1_dt << [spmi_dm__dm_spmi_piece_bill_fee_aggr1_dt,time_after_07_00]


tidb_dm_spmi_piece_bill_fee_aggr3_dt = BashOperator(
    task_id='tidb_dm_spmi_piece_bill_fee_aggr3_dt',
    execution_timeout=timedelta(hours=5),
    email=['lukunming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    bash_command="spmi_fee_domain/dm/tidb/tidb_dm_spmi_piece_bill_fee_aggr_dt/execute.sh",
    pool='spmi_piece',
    retries=0,
    pool_slots=1,
    params={'tidb_host':tidb_host,'tidb_port':tidb_port,'tidb_url':tidb_url,'tidb_user':tidb_user,'tidb_password':tidb_password,'hive_table':hive_table3,'tidb_table':tidb_table3,'if_partitions':if_partitions,'interval_dt':interval_dt,'sqoop_maps':sqoop_maps}

)

tidb_dm_spmi_piece_bill_fee_aggr3_dt << spmi_dm__dm_spmi_piece_bill_fee_aggr3_dt

tidb_dm_spmi_piece_bill_fee_aggr5_dt = BashOperator(
    task_id='tidb_dm_spmi_piece_bill_fee_aggr5_dt',
    execution_timeout=timedelta(hours=5),
    email=['lukunming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    bash_command="spmi_fee_domain/dm/tidb/tidb_dm_spmi_piece_bill_fee_aggr_dt/execute.sh",
    pool='spmi_piece',
    retries=0,
    pool_slots=1,
    params={'tidb_host':tidb_host,'tidb_port':tidb_port,'tidb_url':tidb_url,'tidb_user':tidb_user,'tidb_password':tidb_password,'hive_table':hive_table5,'tidb_table':tidb_table5,'if_partitions':if_partitions,'interval_dt':interval_dt,'sqoop_maps':sqoop_maps}

)

tidb_dm_spmi_piece_bill_fee_aggr5_dt << [spmi_dm__dm_spmi_piece_bill_fee_aggr5_dt,time_after_06_30]